package ds;

/**
 * @Author: zhang
 * @Description:
 * @Date: Created in 15:29 2019/9/16
 */

public class ListTest {
    class Node{
        private int data;
        private Node next;
        public Node(int data){
            this.data = data;
        }
    }

    public static void main(String[] args) {

    }

    //反转链表
    public Node reverseList(Node head){
        Node cur = head;
        Node newHead = null;
        Node prev = null;
        while(cur != null){
            Node curNext = cur.next;
            cur.next = prev;
            prev = cur;
            cur = curNext;
        }
        newHead = prev;
        return newHead;
    }
}
